The same as min, for whole numbers: the smaller of a and b, and the answer is a whole number. Use this one whenever the numbers are counted rather than measured - a lives count, a slot number, a picture number - so the variable you keep it in stays a whole number.
min_int(a, b) -> int| Name | Type |
|---|---|
a | int |
b | int |
int
The same as min, for whole numbers: the smaller of a and b, and the answer is a whole number (so is min's, given whole numbers).
Reach for this one whenever the numbers are counted rather than measured: a lives count, a slot number, which picture of an animation to show. Use min for things that are measured - a position, a speed, a volume.
var strip = min_int(int_floor(x / 32), 5);Works out which 32-pixel-wide strip of the room this object is standing in, and stops counting at strip 5, so an object that has gone past the last strip still counts as strip 5. strip is a whole number, so it can be handed to anything that wants one.
min and min_int do the same arithmetic, and given two whole numbers min already answers a whole number - so picture = min(picture + 1, 5); keeps picture a whole number. The only difference left is strictness: min_int refuses a decimal, so a measured number cannot slip into a counted one unnoticed. (clamp is different - it still answers a decimal; see clamp_int.)
min_int takes whole numbers only. A number with a point in it is a real - even 4.0 - and is refused when the project is checked:
Argument 2 to `min_int` should be an int, but this is a real.If you have a real and want a whole number out of it, round it first with int_floor, int_ceil or int_round. If the numbers really are measured, use min instead.
A whole number is also free of a real's limit: a real runs out at about 524,000 and a whole number does not run out until about 2.1 billion, so min_int(600000, 700000) is 600000.
One comparison - as cheap as this group gets, safe to call every frame.
min and min_int do the same arithmetic. Given two whole numbers, min already hands back a whole number, so min_int is now just a stricter spelling: it refuses a decimal outright, which catches a measured number slipping into a counted one. Both numbers have to be whole: min_int(n, 2.5) is refused when the project is checked, and so is a variable that holds a real, even one that happens to hold 4.0 - round it first with int_floor, int_ceil or int_round. One comparison, cheap enough for every frame.